var express = require('express');
var router = express.Router();
var path = require('path');
var query = require('./Database');
/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('ProMyPoints', {});
});
router.post('/score',async (req,res)=>{
    // console.log(req.body);
    let score = req.body;
    console.log(score);
    let rows = await query("select * from score where userid = "+ score.userid + " and recordsco>0 order by id desc;");
    console.log('+++++++++++++++++++');
    console.log(rows);
    console.log('+++++++++++++++++++');
    let nowsco = await query("select nowsco , sumsco from score where userid = "+ score.userid +" order by id desc limit 1;");
    console.log('--------------------');
    console.log(nowsco);
    console.log('-------------------');
    let data = [{code:100},nowsco,rows];
    res.send(data);
})

module.exports = router;